package com.sneaker.shower.common;

import com.sneaker.shower.entity.domain.organization.OrganizationDO;
import com.sneaker.shower.entity.dto.UserDTO;

public abstract class ThreadLocalCache {
    private static final ThreadLocal<UserDTO> THREAD_LOCAL = new InheritableThreadLocal<>();
    private static final ThreadLocal<OrganizationDO> ORG_THREAD_LOCAL = new InheritableThreadLocal<>();


    public static void set(UserDTO userDTO) {
        THREAD_LOCAL.set(userDTO);
    }

    public static void setOrgThreadLocal(OrganizationDO organizationDO) {
        ORG_THREAD_LOCAL.set(organizationDO);
    }

    public static UserDTO get() {
        return THREAD_LOCAL.get();
    }

    public static OrganizationDO getOrg() {
        return ORG_THREAD_LOCAL.get();
    }

    public static String getUserGuid() {
        return THREAD_LOCAL.get().getGuid();
    }
}
